﻿using Admin.Repository;
using Admin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Admin.Repository
{
     public interface IBaseRepository<Entity>
        where Entity : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Entity Create(Entity entity);

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
         Entity Update(Entity entity);

        /// <summary>
        /// 查询数据 带条件直接查询
        /// </summary>
        /// <returns></returns>
        IQueryable<Entity> Queryable();

        /// <summary>
        /// 查询数据 查询全部
        /// 把所有数据查出来，然后再找到自己需要的信息
        /// </summary>
        /// <returns></returns>
        List<Entity> QueryToList();

        /// <summary>
        /// 根据id查询一条数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Entity QueryId(int id);

        /// <summary>
        /// 查询全部数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        List<Entity> QueryList(Expression<Func<Entity, bool>> predicate);

        /// <summary>
        /// 删除 单删 通过主键
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete(int id);
        /// <summary>
        /// 删除 单删 通过实体
        /// </summary>
        /// <returns></returns>
        int Delete(Entity entity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        int Delete(Expression<Func<Entity, bool>> predicate);

        /// <summary>
        /// 删除 批删 通过主键
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        int Delete(int[] ids);
        /// <summary>
        /// 删除 批删 通过实体
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        int Delete(List<Entity> entity);
    }
}
